const state = {
  theme: '', // 导航主题（light|dark）
  layout: '', // 导航位置（sidemenu|topmenu）
  color: null // 主题色
}

const mutations = {
  TOGGLE_THEME: (state, theme) => {
    localStorage.setItem('DEFAULT_THEME', theme)
    state.theme = theme
  },
  TOGGLE_LAYOUT_MODE: (state, mode) => {
    localStorage.setItem('DEFAULT_LAYOUT_MODE', mode)
    state.layout = mode
  },
  TOGGLE_COLOR: (state, color) => {
    localStorage.setItem('DEFAULT_COLOR', color)
    state.color = color
  }
}

const actions = {
  ToggleTheme ({ commit }, theme) {
    commit('TOGGLE_THEME', theme)
  },
  ToggleLayoutMode ({ commit }, mode) {
    commit('TOGGLE_LAYOUT_MODE', mode)
  },
  ToggleColor ({ commit }, color) {
    commit('TOGGLE_COLOR', color)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
